package com.ymatou.iapi.optrade.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.optrade.resp.TradingServiceResp;
import com.ymatou.iapi.optrade.service.ConfirmReceiveNotifyCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymt.utils.tag.P3;
import com.ymttest.business.service.YMTTrading.TradingCallService;

/**
 * 自动确认收货提醒通知FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_AutoConfirmReceiveNotify {

	private static ConfirmReceiveNotifyCall confirmReceiveNotifyCall;

	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("买家确认收货");
	}

	@Before
	public void caseUp() {

		confirmReceiveNotifyCall = new ConfirmReceiveNotifyCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(confirmReceiveNotifyCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_AutoConfirmReceiveNotify_001() {
		Logger.start(true, "订单下所有面单都已签收");
		try {

			TradingServiceResp placeOrderResp = TradingCallService
					.orderAccept();

			long orderId = placeOrderResp.getOrderList().get(0).getOrderId();
			long sellerId = placeOrderResp.getOrderList().get(0).getSellerId();

			//发货
			TradingCallService.delivery(sellerId, orderId, true);

			String billNo1 = "DB11320536300";

			// 码头保存物流单号
			TradingCallService.saveDeliverSummary(orderId, sellerId, billNo1);

			// 发送请求
			confirmReceiveNotifyCall.setData("{}");
			confirmReceiveNotifyCall.callService();
			Logger.verifyEquals("ok", confirmReceiveNotifyCall.getReturnData(),
					"验证接口返回");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category(P3.class)
	@TestCase
	// notify_order_to_be_auto_confirm_received 发通知 消息
	public void Tc_AutoConfirmReceiveNotify_002() {
		Logger.start(false, "订单下所有面单有未签收");
		try {
			

			// 发送请求
			confirmReceiveNotifyCall.setData("{}");
			confirmReceiveNotifyCall.callService();
			Logger.verifyEquals("ok", confirmReceiveNotifyCall.getReturnData(),
					"验证接口返回");

		} catch (Exception e) {
			Logger.fail(e);
		}
	}

}
